*November 16, 2025
**Wilk, Deza, Hodge, Danagoulian (2025) Couch-Locked with the Munchies: Effects of Recreational Marijuana Laws on Exercise and Nutrition


local count = 0
local path `" "18/12/31" "19/01/07" "19/01/14" "19/01/21" "19/01/28" "19/02/04" "19/02/11" "19/02/18" "19/02/25" "19/03/04" "19/03/11" "19/03/18" "19/03/25" "19/04/01" "19/04/08" "19/04/15" "19/04/22" "19/04/29" "19/05/06" "19/05/13" "19/05/20" "19/05/27" "19/06/03" "19/06/10" "19/06/17" "19/06/24" "19/07/01" "19/07/08" "19/07/15" "19/07/22" "19/07/29" "19/08/05" "19/08/12" "19/08/19" "19/08/26" "19/09/02" "19/09/09" "19/09/16" "19/09/23" "19/09/30" "19/10/07" "19/10/14" "19/10/21" "19/10/28" "19/11/04" "19/11/11" "19/11/18" "19/11/25" "19/12/02" "19/12/09" "19/12/16" "19/12/23" "19/12/30" "20/01/06" "20/01/13" "20/01/20" "20/01/27" "20/02/03" "20/02/10" "20/02/17" "20/02/24" "20/03/02" "20/03/09" "20/03/16" "20/03/23" "20/03/30" "20/04/06" "20/04/13" "20/04/20" "20/04/27" "20/05/04" "20/05/11" "20/05/18" "20/05/25" "20/06/01" "20/06/08" "20/06/15" "20/06/22" "20/06/29" "20/07/06" "20/07/13" "20/07/20" "20/07/27" "20/08/03" "20/08/10" "20/08/17" "20/08/24" "20/08/31" "20/09/07" "20/09/14" "20/09/21" "20/09/28" "20/10/05" "20/10/12" "20/10/19" "20/10/26" "20/11/02" "20/11/09" "20/11/16" "20/11/23" "20/11/30" "20/12/07" "20/12/14" "20/12/21" "20/12/28" "21/01/04" "21/01/11" "21/01/18" "21/01/25" "21/02/01" "21/02/08" "21/02/15" "21/02/22" "21/03/01" "21/03/08" "21/03/15" "21/03/22" "21/03/29" "21/04/05" "21/04/12" "21/04/19" "21/04/26" "21/05/03" "21/05/10" "21/05/17" "21/05/24" "21/05/31" "21/06/07" "21/06/14" "21/06/21" "21/06/28" "21/07/05" "21/07/12" "21/07/19" "21/07/26" "21/08/02" "21/08/09" "21/08/16" "21/08/23" "21/08/30" "21/09/06" "21/09/13" "21/09/20" "21/09/27" "21/10/04" "21/10/11" "21/10/18" "21/10/25" "21/11/01" "21/11/08" "21/11/15" "21/11/22" "21/11/29" "21/12/06" "21/12/13" "21/12/20" "21/12/27" "22/01/03" "22/01/10" "22/01/17" "22/01/24" "22/01/31" "22/02/07" "22/02/14" "22/02/21" "22/02/28" "22/03/07" "22/03/14" "22/03/21" "22/03/28" "22/04/04" "22/04/11" "22/04/18" "22/04/25" "22/05/02" "22/05/09" "22/05/16" "22/05/23" "22/05/30" "22/06/06" "22/06/13" "22/06/20" "22/06/27" "22/07/04" "22/07/11" "22/07/18" "22/07/25" "22/08/01" "22/08/08" "22/08/15" "22/08/22" "22/08/29" "22/09/05" "22/09/12" "22/09/19" "22/09/26" "22/10/03" "22/10/10" "22/10/17" "22/10/24" "22/10/31" "22/11/07" "22/11/14" "22/11/21" "22/11/28" "22/12/05" "22/12/12" "22/12/19" "22/12/26" "'
foreach i of local path {
	di "`i'"
	cd "${base}advan"
	local count = `count' + 1
	local weekly : dir "weekly_patterns/`i'/" files "core_*.csv"
	local total_ : word count `weekly'
	di `total_'
	forvalue z=1/`total_' {
		import delimited using "weekly_patterns/`i'/core_poi-geometry-patterns-part`z'.csv", clear
		drop if iso_country_code == "CA"
		drop if region == "AB" | region == "AS" | region == "BC" | region == "GU" | region == "MB" | region == "NB" | region == "NL" | region == "NS" | region == "NT" | region == "NU" | region == "ON" | region == "PE" | region == "PR" | region == "QC" | region == "SK" | region == "VI" | region == "YT"
		drop if raw_visit_counts == .
		if `count' <= 193 {
			keep placekey location_name brands top_category-postal_code category_tags-tracking_closed_since date_range_start-visits_by_day poi_cbg-related_same_week_brand normalized_visits_by_state_scali-v52
		} // if loop 1
		else {
			keep placekey location_name brands top_category-postal_code category_tags-tracking_closed_since date_range_start-visits_by_day poi_cbg-related_same_week_brand normalized_visits_by_state_scali-v50
		} // else loop 1
		capture confirm numeric variable postal_code
		if !_rc {
			tostring postal_code, replace format(%05.0f)
		} // if loop 2
		capture confirm numeric variable poi_cbg
		if !_rc {
			format poi_cbg %012.0f
			tostring poi_cbg, replace format(%012.0f)
		} // if loop 3
		gen date = date(substr(date_range_start,1,strpos(date_range_start,"T")-1),"YMD")
		* these dates are recorded at the month-year level; date defaults to first of the month
		gen opened = date(opened_on, "YM")
		gen closed = date(closed_on, "YM")
		gen tracking = date(tracking_closed_since, "YM")
		format date opened closed tracking %td
		drop opened_on-tracking_closed_since
		gen wy = `count'
		save "weekly_patterns/`i'/wk_`count'_`z'.dta", replace
	} // week loop
	use "weekly_patterns/`i'/wk_`count'_1.dta", clear
	forvalue x=2/`total_' {
		append using "weekly_patterns/`i'/wk_`count'_`x'.dta"
	} // append loop
	save "weekly_patterns/week_`count'.dta", replace
	* need to change the current directory to location of file to be erased for it to work
	cd "${base}advan/weekly_patterns/`i'"
	forvalues y=1/`total_' {
		erase "wk_`count'_`y'.dta"
	} // erase loop
}
clear

cd "${munchies}"
forvalues j=1/209 {
	use "weekly_patterns/week_`j'.dta"
	drop if region == "MP"
	if `j' >= 194{
		rename v50 v52
		capture: rename v48 v50
	} // week loop
	gen disp = 0
	local name Cannabis cannabis CANNABIS CannaB "Canna " Cannasales Cannazone Cannis cannis Dispensary dispensary "Weed " Weedology Weedy Weedery Marijuana marijuana Marihuana 420 4Twenty "Kush " "Kushery" "Dank " "Best Buds" Pharmz "Utopia Gardens" "Snoops Doggz" Skymint Pleasantrees "Verde Natural" "Planet 13" "Uncle Ike" "Apothecary Farms" "Budz " " Budz" "THC " " THC" MMJ "Dr Reefer" "Reefer Madness" Doobie Doobees Fillabong "Rec 21" "Pot Shop" "Starbuds"
	foreach i of local name {
		replace disp = 1 if strpos(location_name, "`i'")
	} // name loop
	* Bring in 4 specific states dispensaries with 3 or more locations listed & does not contain prior catch words *
	**** COLORADO *****
	local colorado "Buddy Boy" `" "Callie's" "' "Colorado Harvest" "Emerald Fields" "Golden Meds" "Good Chemistry" "Green Dragon" "Green Cross" "High Level Health" "High Q " "Igadi" "Lightshade" "LivWell" "LOVA" `" "Maggie's Farm" "' "Medicine Man" "Native Roots" "Rocky Mountain High" "Roots Rx" "Star Buds" "Strawberry Fields" "Terrapin Care" "Green Joint" "Kind Castle" "The Lodge" "Tweedleaf"
	foreach co of local colorado {
		replace disp = 1 if strpos(location_name, `"`co'"') & region == "CO"
	} // CO name loop
	***** MAINE *****
	local maine "Alternative Essence" "Atlantic Farms" "Black Bear Buds" "Fire on Fore" "Firestorm" "Grass Monkey" "GRM Shop" "Humble Family Farms" "Just Baked" "Kind & Co" "Kind Farm Reserve" "Mystique of Maine" "Portland Greenhouse" "Pot of Gold" "Rock Steady" "Rose Mary Jane" "Royal Leaf Apothecary" "Schedule 1" "Sinsemilla" "Stache" "Sweet Dirt" "The Hideaway" "Atlantic Puffin" "Healing Community MEDCo" "The Joint" "Theory Wellness" "Unity Rd" "Venus and Mars" "Wellness Connection"
	foreach me of local maine {
		replace disp = 1 if strpos(location_name, `"`me'"') & region == "ME"
	} // ME name loop
	***** MASSACHUSETTS *****
	* have to find specific business names from the owning entity
	local massachusetts "Alternative Therapies" "Apothca" "Atlantic Medicinal Partners" "Beacon Compassion" "CNA Stores" "Curaleaf" "Cypress Tree" "Ember Gardens" "Emerald River" "Evergreen Strategies" "Garden Remedies" "Green Biz" "Green Era" "GreenStar" "Holistic Industries" "MassMedicum" "Mayflower Med" "Metro Harvest" "The Vault" `" "Nature's Med" "' `" "Nature's Remedy" "' "Craft Cultivators" "Patriot Care" "Pure Oasis" "Red Cardinal" "Resinate" "Sanctuary Medicinals" "Silver Therapeutics" "Sira Naturals" "Temescal Wellness" "Haven Center" "Theory Wellness" "ToroVerde" "Union Twist" "Western Front"
	foreach ma of local massachusetts {
		replace disp = 1 if strpos(location_name, `"`ma'"') & region == "MA"
	} // MA name loop
	***** WASHINGTON *****
	local washington "2020 Solutions" "20 After 4" "Green Life" "American Harvest" "Better Buds" "Bud Barn" "Bud Hut" "Cinder" `" "Dank's Wonder" "' "Euphorium" "Evergreen Market " "Evergreen Meadows" "Exponential 3" "Five Points" "Floral Fanatix" "Freedom Market" "Green Grotto" "Green Leaf Rec" "Green Theory" "Green2Go" "Greenhand" "Greenside" "Gringo Caliente" "Happy Time" "Have a Heart" "Herbal E Scents" "Herbal Legends" "High 502" "High Society" "Hypeherbally" "Kaleafa" "Keystone Creations" "King Cronic" "Kush21" "Kushman" "Living Well Ent" "Local Roots" "Local Amster" "Lovely Buds" "Lucid" "Lucky Leaf" "Lux Pot" `" "Mary Jane's'" "' "Mary Mart " "Modern Creations" "One Love" "Pot Zone" "PRC" "Satori" "Seattle Trees Collective" "Seedz" "The Bake Shop" "Bakeree" "The Grass" "Green Nugget" "Green Seed" "Happy Crop" "Herbal Gardens" "The Herbery" "The Joint" "The Reef" "The Slow Burn" "The Vault" "Western Bud"
	foreach wa of local washington {
		replace disp = 1 if strpos(location_name, `"`wa'"') & region == "WA"
	} // WA name loop
	* filter names that are clearly not marijuana associated
	local filter Grill Coffee Burrito Donut Doughnut Tacos Nacho "Ice Cream" Beer Book Wine Distillers Liquor Hops Brewery Automotive "Car " Hookah nurse "Kush Boutique" Gallery "Fine Art" Gaming Elementary "420 Card" "Town Park" "Beach Park" "Weed Park" "54Twenty" Skatepark Library Hospital Airport DDS Dermatology Chiropractic Police Endodontics "Bible Church" "420 West" "Holistic Center" "Hot Chicken" Hostel "Total Health" "BiDog" "Eye Clinic" Eyecare Optical "Hy Vee" Paint Kula "Winter Shelter" "4201" Mattress "4420" "1420" "St Thomas" "4201" Pest "Music &" "Body Shop" "Driving Range" "410 420" Funeral Dentist "Golf Course" "Superior Court" "4200" "7420" "1420" "4205" Salon Restaurant Garden "High School" Casino Beauty "Sage and Cinder" Cinderella Tattoo Coaching Glass Kindergarten Museum Guitars Food
	foreach k of local filter {
		replace disp = 0 if strpos(location_name, "`k'") & disp == 1
	} // clean name loop
	* Capture all cannabis category providers *
	gen cat = 0
	replace cat = 1 if strpos(category_tag, "Cannabis")
	* Drop places that are most likely supplements, herbal storees, CBD retailers, etc.
	local alt Alternative Acupuncture Addiction "Bar or Pub" Vitamin Supplement Cosmetics Chiropractic Herbs
	foreach a of local alt {
		replace cat = 0 if strpos(category_tag, "`a'") & cat == 1
	} // category loop
	* Drop places from large dispensary catch that are not feasibly related to marijuana
	local drop Food Clothing Optician Orthopedist Marketing Printing "Car Wash" Tires Truck Golf Church BBQ Alcohol Auto Brewery Pub Arts Bakery Beaches Cafe Vitamin Supplement Cosmetics Salad "Real Estate" Djs HVAC Tours Sandwich Yoga Fire Protection Tattoo Brunch Jewelry Security Farming Hearing Hair Dermatology Packing "Car Dealers" Kitchen Smoothie Office Acupuncture "RV Park" Movers Condo Carpenter Campground "Body Shop" Repair Security "Sports Team" Furniture Contractors Accountant Podiatrist Chicken
	foreach d of local drop {
		replace disp = 0 if strpos(category_tag, "`d'") & disp == 1 & cat == 0
	} // drop loop
	replace disp = 1 if cat ==1
	* Identify Medical Places 
	gen medical = 0
	local med CBD Medicinal Medicine Medical Healing Therapy Wellness "Care Docs" MD Rx RX Doctor doctor Meditation MMJ Herbology Massage Neurology Hemp Zen TruMed TreeMed "Dr Reefer" Natural Remedy Remedies
	foreach m of local med {
		replace medical = 1 if strpos(location_name, "`m'") & disp == 1
	} // med loop
	local medcat Medical Medicinal Mental Clinic Doctor
	foreach mc of local medcat {
		replace medical = 1 if strpos(category_tag, "`mc'") & disp == 1
	} // medcat loop
	***** Need to zero any provider in a state that is popping for disp or medical BEFORE law passed AND
		* Need to change any disp to medical if state has only medical or is before passage of RMJ
		* OR just mark which states have MMJ or RMJ laws and when; but do at later time
	* Bring in fast food restaurants, sit down, liquor stores, grocery, bars, movies, etc.
	local place fast confood grocery dollar liquor
	foreach p of local place {
		gen `p' = 0
	} // food gen loop
	replace fast = 1 if naics_code == 722513
	replace confood = 1 if naics_code == 445120
	replace grocery = 1 if naics_code == 44511 | naics_code == 445110
		* potential for grocery delivery service
	replace dollar = 1 if naics_code == 452319
	replace liquor = 1 if naics_code == 445310
	if `j' >= 158 {
		local twenty2 fast confood grocery dollar liquor
		foreach t of local twenty2 {
			gen `t'2 = 0
		} // food alt loop
		replace fast2 = 1 if naics_code == 722513
		replace confood2 = 1 if naics_code == 445131
		replace grocery2 = 1 if naics_code == 44511 | naics_code == 445110
		replace dollar2 = 1 if naics_code == 455219
		replace liquor2 = 1 if naics_code == 455320
		
		local total fast confood grocery dollar liquor
		foreach s of local total {
			gen `s'_t = `s' + `s'2
			replace `s'_t = 1 if `s'_t > 1
			drop `s' `s'2
			rename `s'_t `s'
		} // combine food loop
	} // if week loop
	local double fast confood grocery dollar liquor
	foreach d of local double {
		replace `d' = 0 if disp == 1 & `d' == 1
	} // clean loop
	gen mj = 0
	replace mj = 1 if disp == 1 | cat == 1 | medical == 1
	gen category = 0
	replace category = 1 if mj == 1
	replace category = 2 if fast == 1
	replace category = 3 if confood == 1 
	replace category = 4 if grocery == 1 
	replace category = 5 if dollar == 1 
	replace category = 6 if liquor == 1 
	replace category = 7 if movie == 1 
	replace category = 8 if sit == 1 
	replace category = 9 if bar == 1 
	replace category = 10 if auto == 1 
	replace category = 11 if furn == 1 
	replace category = 12 if cloth == 1
	replace category = 13 if dept == 1
	drop if category == 0
	* drop ~75% of observations
	save "Loops/wk_`j'.dta", replace
	clear all
} // weeks looop
use "Loops/wk_1.dta", clear
forvalues i=2/209 {
	append using "Loops/wk_`i'.dta"
} // append loop
save "cannabis_wk_1.dta", replace


***** POI Level *****
use "cannabis_wk_v1.dta", clear
gen ct = substr(poi_cbg,1,11)
gen year = year(date)
replace year = 2019 if wy == 1
gen yr = string(year)
gen cty = ct + yr
gen fips = substr(ct,1,5)
drop if fips == "."
drop if poi_cbg == ""
gen fpy = fips + yr
drop yr
drop street_address city date_range_start date_range_end visitor_home_cbgs-visitor_daytime_cbgs

* Bring in ACS data
merge m:1 fpy using "acs1922new_cn.dta", keep(master merged) nogen
destring fips st, replace force

gen eff = 0
gen start = 0
gen post_eff = 0
gen post_start = 0
gen shelter = 0
*************************
***** NOTE: need to make dates mutually exclusive and have it set up e2e or s2s
	* eff == mml_eff date to rml_eff date & start = mml_start date to rml_start date
***** NOTE: create shelter in place dummy using stop and start dates
* Alabama (AL | 01)
replace eff = 1 if date >= td(17may2021) & region == "AL"
*replace post_eff = 1 if region == "AL"
*replace start = 1 if region == "AL"
*replace post_start = 1 if region == "AL"
replace shelter = 1 if date >= td(04apr2020) & date < td(30apr2020) & region == "AL"
* Alaska (AK | 02)
replace eff = 1 if date >= td(04mar1999) & date < td(24feb2015) & region == "AK" 
replace post_eff = 1 if date >= td(24feb2015) & region == "AK"
*replace start = 1 if region == "AK"
replace post_start = 1 if date >= td(29oct2016) & region == "AK"
replace shelter = 1 if date >= td(28mar2020) & date < td(24apr2020) & region == "AK"
* Arizona (AZ | 04)
replace eff = 1 if date >= td(14mar2011) & date < td(30nov2020) & region == "AZ" 
replace post_eff = 1 if date >= td(30nov2020) & region == "AZ"
replace start = 1 if date >= td(06dec2012) & date < td(22jan2021) & region == "AZ"
replace post_start = 1 if date >= td(22jan2021) & region == "AZ"
replace shelter = 1 if date >= td(31mar2020) & date < td(16may2020) & region == "AZ"
* Arkansas (AR | 05)
replace eff = 1 if date >= td(09nov2016) & region == "AR" 
*replace post_eff = 1 if region == "AR"
replace start = 1 if date >= td(11may2019) & region == "AR"
*replace post_start = 1 if region == "AR"
*replace shelter = 1 if region == "AR"
* California (CA | 06)
replace eff = 1 if date >= td(06nov1996) & date < td(09nov2016) & region == "CA"
replace post_eff = 1 if date >= td(09nov2016) & region == "CA"
replace start = 1 if date >= td(01jan218) & date < td(01jan2018) & region == "CA"
replace post_start = 1 if date >= td(01jan2018) & region == "CA"
replace shelter = 1 if date >= td(19mar2020) & date < td(25jan2021) & region == "CA"
* Colorado (CO | 08)
replace eff = 1 if date >= td(01jun2001) & date < td(10dec2012) & region == "CO"
replace post_eff = 1 if date >= td(10dec2012) & region == "CO"
replace start = 1 if date >= td(10oct2011) & date < td(01jan2014) & region == "CO"
replace post_start = 1 if date >= td(01jan2014) & region == "CO"
replace shelter = 1 if date >= td(26mar2020) & date < td(27apr2020) & region == "CO"
* Connecticut (CT | 09)
replace eff = 1 if date >= td(01oct2012) & date < td(01jul2021) & region == "CT"
replace post_eff = 1 if date >= td(01jul2021) & region == "CT"
replace start = 1 if date >= td(20aug2014) & date < td(10jan2023) & region == "CT"
replace post_start = 1 if date >= td(10jan2023) & region == "CT"
replace shelter = 1 if date >= td(23mar2020) & date < td(20may2020) & region == "CT"
* Delaware (DE | 10)
replace eff = 1 if date >= td(01jul2011) & date < td(23apr2023) & region == "DE"
replace post_eff = 1 if date >= td(23apr2023) & region == "DE"
replace start = 1 if date >= td(26jun2015) & date < td(01jun2024) & region == "DE"
replace post_start = 1 if date >= td(01jun2024) & region == "DE"
replace shelter = 1 if date >= td(24mar2020) & date < td(01jun2020) & region == "DE"
* District of Columbia (DC | 11)
replace eff = 1 if date >= td(01jan2011) & date < td(26feb2015) & region == "DC"
replace post_eff = 1 if date >= td(26feb2015) & region == "DC"
replace start = 1 if date >= td(30jul2013) & date < td(26feb2015) & region == "DC"
replace post_start = 1 if date >= td(26feb2015) & region == "DC"
replace shelter = 1 if date >= td(01apr2020) & date < td(29may2020) & region == "DC"
* Florida (FL | 12)
replace eff = 1 if date >= td(25mar2016) & region == "FL"
*replace post_eff = 1 if region == "FL"
replace start = 1 if date >= td(26jul2016) & region == "FL"
*replace post_start = 1 if region == "FL"
replace shelter = 1 if date >= td(03apr2020) & date < td(18may2020) & region == "FL"
* Georgia (GA | 13)
	* NONE *
replace shelter = 1 if date >= td(03apr2020) & date < td(01may2020) & region == "GA"
* Hawaii (HI | 15)
replace eff = 1 if date >= td(28dec2000) & region == "HI"
*replace post_eff = 1 if region == "HI"
replace start = 1 if date >= td(08aug2017) & region == "HI"
*replace post_start = 1 if region == "HI"
replace shelter = 1 if date >= td(25mar2020) & date < td(31may2020) & region == "HI"
* Idaho (ID | 16)
	* NONE *
replace shelter = 1 if date >= td(25mar2020) & date < td(01may2020) & region == "ID"
* Illinois (IL | 17)
replace eff = 1 if date >= td(01jan2014) & date < td(01jan2020) & region == "IL"
replace post_eff = 1 if date >= td(01jan2020) & region == "IL"
replace start = 1 if date >= td(09nov2015) & date < td(01jan2020) & region == "IL"
replace post_start = 1 if date >= td(01jan2020) & region == "IL"
replace shelter = 1 if date >= td(21mar2020) & date < td(29may2020) & region == "IL"
* Indiana (IN | 18)
	* NONE *
replace shelter = 1 if date >= td(25mar2020) & date < td(18may2020) & region == "IN"
* Iowa (IA | 19)
	* NONE *
* Kansas (KS | 20)
	* NONE *
replace shelter = 1 if date >= td(30mar2020) & date < td(04may2020) & region == "KS"
* Kentucky (KY | 21)
	* NONE *
replace shelter = 1 if date >= td(26mar2020) & date < td(29jun2020) & region == "KY"
* Louisiana (LA | 22)
replace eff = 1 if date >= td(19may2016) & region == "LA"
*replace post_eff = 1 if region == "LA"
replace start = 1 if date >= td(06aug2019) & region == "LA"
*replace post_start = 1 if region == "LA"
replace shelter = 1 if date >= td(23mar2020) & date < td(15may2020) & region == "LA"
* Maine (ME | 23)
replace eff = 1 if date >= td(22dec1999) & date < td(30jan2017) & region == "ME"
replace post_eff = 1 if date >= td(30jan2017) & region == "ME"
replace start = 1 if date >= td(01mar2011) & date < td(09oct2020) & region == "ME"
replace post_start = 1 if date >= td(09oct2020) & region == "ME"
replace shelter = 1 if date >= td(02apr2020) & date < td(31may2020) & region == "ME"
* Maryland (MD | 24)
replace eff = 1 if date >= td(01jun2014) & date < td(01jul2023) & region == "MD"
replace post_eff = 1 if date >= td(01jul2023) & region == "MD"
replace start = 1 if date >= td(01dec2017) & date < td(01jul2023) & region == "MD"
replace post_start = 1 if date >= td(01jul2023) & region == "MD"
replace shelter = 1 if date >= td(30mar2020) & date < td(15may2020) & region == "MD"
* Massachuesetts (MA | 25)
replace eff = 1 if date >= td(01jan2013) & date < td(15dec2016) & region == "MA"
replace post_eff = 1 if date >= td(15dec2016) & region == "MA"
replace start = 1 if date >= td(24jun2015) & date < td(20nov2018) & region == "MA"
replace post_start = 1 if date >= td(20nov2018) & region == "MA"
replace shelter = 1 if date >= td(24mar2020) & date < td(18may2020) & region == "MA"
* Michigan (MI | 26)
replace eff = 1 if date >= td(04dec2008) & date < td(06dec2018) & region == "MI"
replace post_eff = 1 if date >= td(06dec2018) & region == "MI"
replace start = 1 if date >= td(01aug2018) & date < td(01dec2019) & region == "MI"
replace post_start = 1 if date >= td(01dec2019) & region == "MI"
replace shelter = 1 if date >= td(24mar2020) & date < td(01jun2020) & region == "MI"
* Minnesota (MN | 27)
replace eff = 1 if date >= td(29may2014) & date < td(01aug2023) & region == "MN"
replace post_eff = 1 if date >= td(01aug2023) & region == "MN"
replace start = 1 if date >= td(01jul2015) & region == "MN"
*replace post_start = 1 if region == "MN"
replace shelter = 1 if date >= td(28mar2020) & date < td(18may2020) & region == "MN"
* Mississippi (MS | 28)
replace eff = 1 if date >= td(02feb2022) & region == "MS"
*replace post_eff = 1 if region == "MS"
replace start = 1 if date >= td(25jan2023) & region == "MS"
*replace post_start = 1 if region == "MS"
replace shelter = 1 if date >= td(03apr2020) & date < td(27apr2020) & region == "MS"
* Missouri (MO | 29)
replace eff = 1 if date >= td(06dec2018) & date < td(08dec2022) & region == "MO"
replace post_eff = 1 if date >= td(08dec2022) & region == "MO"
replace start = 1 if date >= td(17oct2020) & date < td(03feb2023) & region == "MO"
replace post_start = 1 if date >= td(03feb2023) & region == "MO"
replace shelter = 1 if date >= td(06apr2020) & date < td(04may2020) & region == "MO"
* Montana (MT | 30)
replace eff = 1 if date >= td(02nov2004) & date < td(01jan2021) & region == "MT"
replace post_eff = 1 if date >= td(01jan2021) & region == "MT"
replace start = 1 if date >= td(01apr2018) & date < td(01jan2022) & region == "MT"
replace post_start = 1 if date >= td(01jan2022) & region == "MT"
replace shelter = 1 if date >= td(28mar2020) & date < td(26apr2020) & region == "MT"
* Nebraska (NE | 31)
	* NONE *
* Nevada (NV | 32)
replace eff = 1 if date >= td(01oct2001) & date < td(01jan2017) & region == "NV"
replace post_eff = 1 if date >= td(01jan2017) & region == "NV"
replace start = 1 if date >= td(31jul2015) & date < td(01jul2017) & region == "NV"
replace post_start = 1 if date >= td(01jul2017) & region == "NV"
replace shelter = 1 if date >= td(31mar2020) & date < td(09may2020) & region == "NV"
* New Hampshire (NH | 33)
replace eff = 1 if date >= td(23may2013) & region == "NH"
*replace post_eff = 1 if region == "NH"
replace start = 1 if date >= td(01may2016) & region == "NH"
*replace post_start = 1 if region == "NH"
replace shelter = 1 if date >= td(28mar2020) & date < td(16jun2020) & region == "NH"
* New Jersey (NJ | 34)
replace eff = 1 if date >= td(01jul2010) & date < td(22feb2021) & region == "NJ"
replace post_eff = 1 if date >= td(22feb2021) & region == "NJ"
replace start = 1 if date >= td(01jan2012) & date < td(20apr2022) & region == "NJ"
replace post_start = 1 if date >= td(20apr2022) & region == "NJ"
replace shelter = 1 if date >= td(21mar2020) & date < td(09jun2020) & region == "NJ"
* New Mexico (NM | 35)
replace eff = 1 if date >= td(01jul2007) & date < td(29jun2021) & region == "NM"
replace post_eff = 1 if date >= td(29jun2021) & region == "NM"
replace start = 1 if date >= td(01jan2010) & date < td(01apr2022) & region == "NM"
replace post_start = 1 if date >= td(01apr2022) & region == "NM"
replace shelter = 1 if date >= td(24mar2020) & date < td(30nov2020) & region == "NM"
* New York (NY | 36)
replace eff = 1 if date >= td(05jul2014) & date < td(31mar2021) & region == "NY"
replace post_eff = 1 if date >= td(31mar2021) & region == "NY"
replace start = 1 if date >= td(07jan2016) & date < td(29dec2022) & region == "NY"
replace post_start = 1 if date >= td(29dec2022) & region == "NY"
replace shelter = 1 if date >= td(22mar2020) & date < td(27jun2020) & region == "NY"
* North Carolina (NC | 37)
	* NONE *
replace shelter = 1 if date >= td(30mar2020) & date < td(22may2020) & region == "NC"
* North Dakota (ND | 38)
replace eff = 1 if date >= td(18apr2017) & region == "ND"
*replace post_eff = 1 if region == "ND"
replace start = 1 if date >= td(01mar2019) & region == "ND"
*replace post_start = 1 if region == "ND"
*replace shelter = 1 if region == "ND"
* Ohio (OH | 39)
replace eff = 1 if date >= td(08sep2016) & region == "OH"
*replace post_eff = 1 if region == "OH"
replace start = 1 if date >= td(16jan2019) & region == "OH"
*replace post_start = 1 if region == "OH"
replace shelter = 1 if date >= td(24mar2020) & date < td(20may2020) & region == "OH"
* Oklahoma (OK | 40)
replace eff = 1 if date >= td(26jun2018) & region == "OK"
*replace post_eff = 1 if region == "OK"
replace start = 1 if date >= td(26oct2018) & region == "OK"
*replace post_start = 1 if region == "OK"
replace shelter = 1 if date >= td(01apr2020) & date < td(15may2020) & region == "OK"
* Oregon (OR | 41)
replace eff = 1 if date >= td(03dec1998) & date < td(01jul2015) & region == "OR"
replace post_eff = 1 if date >= td(01jul2015) & region == "OR"
replace start = 1 if date >= td(21mar2014) & date < td(01oct2015) & region == "OR"
replace post_start = 1 if date >= td(01oct2015) & region == "OR"
replace shelter = 1 if date >= td(23mar2020) & date < td(19jun2020) & region == "OR"
* Pennsylvania (PA | 42)
replace eff = 1 if date >= td(17may2016) & region == "PA"
*replace post_eff = 1 if region == "PA"
replace start = 1 if date >= td(15feb2018) & region == "PA"
*replace post_start = 1 if region == "PA"
replace shelter = 1 if date >= td(01apr2020) & date < td(05jun2020) & region == "PA"
* Rhode Island (RI | 44)
replace eff = 1 if date >= td(03jan2006) & date < td(25may2022) & region == "RI"
replace post_eff = 1 if date >= td(25may2022) & region == "RI"
replace start = 1 if date >= td(01jan2013) & date < td(01dec2022) & region == "RI"
replace post_start = 1 if date >= td(01dec2022) & region == "RI"
replace shelter = 1 if date >= td(28mar2020) & date < td(09may2020) & region == "RI"
* South Carolina (SC | 45)
	* NONE *
replace shelter = 1 if date >= td(07apr2020) & date < td(04may2020) & region == "SC"
* South Dakota (SD | 46)
replace eff = 1 if date >= td(01jul2021) & region == "SD"
*replace post_eff = 1 if region == "SD"
replace start = 1 if date >= td(27jul2022) & region == "SD"
*replace post_start = 1 if region == "SD"
*replace shelter = 1 if region == "SD"
* Tennessee (TN | 47)
	* NONE *
replace shelter = 1 if date >= td(02apr2020) & date < td(29apr2020) & region == "TN"
* Texas (TX | 48)
	* NONE *
replace shelter = 1 if date >= td(02apr2020) & date < td(01may2020) & region == "TX"
* Utah (UT | 49)
replace eff = 1 if date >= td(01dec2018) & region == "UT"
*replace post_eff = 1 if region == "UT"
replace start = 1 if date >= td(02mar2020) & region == "UT"
*replace post_start = 1 if region == "UT"
*replace shelter = 1 if region == "UT"
* Vermont (VT | 50)
replace eff = 1 if date >= td(01jul2004) & date < td(01jul2018) & region == "VT"
replace post_eff = 1 if date >= td(01jul2018) & region == "VT"
replace start = 1 if date >= td(25jun2013) & date < td(01oct2022) & region == "VT"
replace post_start = 1 if date >= td(01oct2022) & region == "VT"
replace shelter = 1 if date >= td(24mar2020) & date < td(15may2020) & region == "VT"
* Virginia (VA | 51)
replace eff = 1 if date >= td(01jul2017) & date < td(01jul2021) & region == "VA"
replace post_eff = 1 if date >= td(01jul2021) & region == "VA"
replace start = 1 if date >= td(17oct2020) & region == "VA"
*replace post_start = 1 if region == "VA"
replace shelter = 1 if date >= td(30mar2020) & date < td(29may2020) & region == "VA"
* Washington (WA | 53)
replace eff = 1 if date >= td(03nov1998) & date < td(06dec2012) & region == "WA"
replace post_eff = 1 if date >= td(06dec2012) & region == "WA"
replace start = 1 if date >= td(08jul2014) & date < td(08jul2014) & region == "WA"
replace post_start = 1 if date >= td(08jul2014) & region == "WA"
replace shelter = 1 if date >= td(23mar2020) & date < td(01jun2020) & region == "WA"
* West Virginia (WV | 54)
replace eff = 1 if date >= td(01jul2019) & region == "WV"
*replace post_eff = 1 if region == "WV"
replace start = 1 if date >= td(12nov2021) & region == "WV"
*replace post_start = 1 if region == "WV"
replace shelter = 1 if date >= td(24mar2020) & date < td(05may2020) & region == "WV"
* Wisconsin (WI | 55)
	* NONE *
replace shelter = 1 if date >= td(25mar2020) & date < td(13may2020) & region == "WI"
* Wyoming (WY | 56)
	* NONE *

***** Generate log values, per capita values for visits & visitors
gen nv_pc = raw_visit_counts/(pop/10000)
gen nvr_pc = raw_visitor_counts/(pop/10000)
gen lnnv = ln(raw_visit_counts + 1)
gen lnnvr = ln(raw_visitor_counts + 1)

gen canna = 0
replace canna = 1 if eff == 1 | post_eff == 1 | start == 1 | post_start == 1

* generate gvar for csdid
gen g_id = 0
replace g_id = . if st == 2 | st == 6 | st == 8 | st == 11 | st == 25 | st == 32 | st == 41 | st == 53
replace g_id = 49 if st == 26
replace g_id = 54 if st == 17
replace g_id = 94 if st == 23
replace g_id = 109 if st == 4
replace g_id = 158 if st == 30
replace g_id = 171 if st == 35
replace g_id = 174 if st == 34
replace g_id = 197 if st == 50
replace g_id = 206 if st == 44

gen Ei = g_id
replace Ei = . if Ei == 0

gen week = .
replace week = 52 if wy == 1
replace week = wy - 1 if wy > 1 & wy <= 53
replace week  = wy - 53 if wy > 53 & wy <= 105
replace week = wy - 105 if wy > 105 & wy <= 157
replace week = wy - 157 if wy > 157

gen yr = .
replace yr = 2018 if wy == 1
replace yr = 2019 if wy > 1 & wy <= 53
replace yr = 2020 if wy > 53 & wy <= 105
replace yr = 2021 if wy > 105 & wy <= 157
replace yr = 2022 if wy > 157

gen treat = 0
replace treat = 1 if g_id > 0

gen period = 0
replace period = wy - g_id if g_id > 0

save "poi_rml.dta", replace

***** End-of-File *****
